<?php echo $this->render($this->includeDir . '/toolbar.php');?>
<?php echo $this->flashMessage();?>
<?php 
	$arrParam = $this->arrParam;
	$this->Item['name'] = Zendvn_Filter_Filter::filterContent($this->Item['name']);
	$name 		= $this->formText('name',$this->Item['name'],array('class'=>'width-300 bg-green2 floatLeft' ));
	
	if(!empty($this->slbParents)){		
		$cat_id 	= $this->cmsSelect('cat_id',$this->Item['cat_id'],
									array('size'=>10,'class'=>'width-150 bg-green2 floatLeft'),
									$this->slbParents);
	}
		
	$picture	= $this->formFile('picture',array('class'=>'floatLeft'));
	if($this->arrParam['action'] == 'edit'){
		$config = new Zendvn_Controller_Config(array('module'=>$arrParam['module'],
												'fileConfig'=>'news-category.ini'));
	 	
	 	$pictureConfig = $config->getConfig('item');
		
		$current_picture = '<div id="load-content-picture" class="clr width-150 center">';
		if(!empty($this->Item['picture'])){
			$pictureUrl = $pictureConfig['thumbUrl1'] . '/' . $this->Item['picture'];
			$removeLink = $this->url(array('action'=>'remove-pic','type'=>'picture','file'=>$this->Item['picture']));
			$current_picture .= '<br>' . $this->cmsImage('picture',$pictureUrl,array('width'=>'75px'))
							. '<br><a  class="remove" href="javascript:loadPage(\'div#load-content-picture\',\'' . $removeLink . '\')">remove</a>';
		}
		
		$current_picture .= $this->formHidden('current_picture',$this->Item['picture'])
						. '</div>';
		$picture .=	$current_picture;		
	}

	$options 		= array('inactive'=>$this->translate('Inactive'),'active'=>$this->translate('Active'));	
	$status 		= $this->formSelect('status',$this->Item['status'],array('class'=>'width-150'),$options);
	
	$summary 		= Zendvn_Filter_Filter::filterContent($this->Item['summary']);
// 	$summary		= $this->tinyMce('summary',$summary,array('style'=>"width: 100%; height: 250px;"));
// 	$summary  		= '<div id="d_summary" style="width:98%; float: left">' . $summary . '</div>';
	$summary 		= $this->formTextarea('summary',$summary,array('rows'=>10));
	$content	 	= Zendvn_Filter_Filter::filterContent($this->Item['content']);
	$content		= $this->tinyMce('content',$content,array('style'=>"width: 100%; height: 350px;"));
	$content  		= '<div id="d_content" style="width:98%; float: left">' . $content . '</div>';
	$file_attach	= $this->formFile('file_attach',array('class'=>'floatLeft'));
	if($this->arrParam['action'] == 'edit'){
		$config = new Zendvn_Controller_Config(array('module'=>$arrParam['module'],
												'fileConfig'=>'news-category.ini'));
	 	
	 	$pictureConfig = $config->getConfig('item');
		
		$current_file_attach = ' ';
		if(!empty($this->Item['file_attach'])){
			$removeLink = $this->url(array('action'=>'remove-pic','type'=>'file','file'=>$this->Item['file_attach']));
			$current_file_attach .= '<div id="load-file">';
			$current_file_attach .= $this->formHidden('current_file_attach',$this->Item['file_attach'],array('class'=>'width-150'))
								 .$this->formText('show_file_attach',$this->Item['file_attach'],array('class'=>'width-150','disable'=>'disable'))
									.'&nbsp;<a  class="remove" href="javascript:loadPage(\'div#load-file\',\'' . $removeLink . '\')">remove</a>';
			$current_file_attach .= '</div>';
		}
		$file_attach .=	$current_file_attach;			
	}
	$this->Item['tags'] = Zendvn_Filter_Filter::filterContent($this->Item['tags']);
	$tags 			= $this->formText('tags',$this->Item['tags'],array('class'=>'width-300 floatLeft' ));
	$this->Item['source_by'] = Zendvn_Filter_Filter::filterContent($this->Item['source_by']);
	$source_by 		= $this->formText('source_by',$this->Item['source_by'],array('class'=>'width-200 floatLeft' ));
	$hits 			= $this->formText('hits',$this->Item['hits'],array('class'=>'width-150 floatLeft' ));
	$this->Item['html_descript'] = Zendvn_Filter_Filter::filterContent($this->Item['html_descript']);
	$html_descript 	= $this->formTextarea('html_descript',$this->Item['html_descript'],array('class'=>'width-400','rows'=>8));
	$this->Item['html_keyword'] = Zendvn_Filter_Filter::filterContent($this->Item['html_keyword']);
	$html_keyword 	= $this->formTextarea('html_keyword',$this->Item['html_keyword'],array('class'=>'width-400','rows'=>8));
	$formHelp 		= '';	
	$config = new Zendvn_Controller_Config(array('module'=>$arrParam['module'],
												'fileConfig'=>'news-category.ini',
												'section'=>'tooltip'));
	$arrTooltip = $config->getConfig('item');	
	if(count($arrTooltip)>0){
		foreach ($arrTooltip as $key => $val){
		   if($key=='d_summary') $attribs = array('leftOffset'=>-305);
		   if($key=='d_content') $attribs = array('leftOffset'=>-305);
		   $formHelp  .= $this->cmsFormHelp('.form-table #' . $key, $this->translate($val), $attribs); 
		}
	}
	
	 if(count($this->errors)>0){	
	 	foreach ($this->errors as $key => $val){	 		
	 		$$key .= $this->cmsError($key,$val);	
	 		$selector = '.form-table #' . $key . '-error';
	 		$options = array('type'=>'error','name'=>'#' .$key);
	 		$formHelp  .= $this->cmsFormHelp($selector, $this->translate($val),null,$options);
	 		
	 	}
	 }
	 $arrRow = array(
					array('label'=>$this->translate('Title'),'input'=>$name),	
					array('label'=>$this->translate('Image'),'input'=>$picture),					
					array('label'=>$this->translate('Category'),'input'=>$cat_id),						
					array('label'=>$this->translate('Description'),'input'=>$summary),						
					array('label'=>$this->translate('Content'),'input'=>$content),
// 					array('label'=>$this->translate('Attach'),'input'=>$file_attach),
// 					array('label'=>$this->translate('Source'),'input'=>$source_by),
// 					array('label'=>$this->translate('Tags'),'input'=>$tags),
// 					array('label'=>$this->translate('views'),'input'=>$hits),
					array('label'=>$this->translate('Html descript'),'input'=>$html_descript),
					array('label'=>$this->translate('Html keywords'),'input'=>$html_keyword),
					array('label'=>$this->translate('Status'),'input'=>$status),
					);
	$tdForm = $this->partialLoop('row.php',$arrRow);
	
?>
<script type="text/javascript">
	$(document).ready(function() {
		<?php echo $formHelp;?>
	});
</script>
<div id="element-box">
	<div class="m">
		<div class="form-table">
        	<fieldset class="admin-fieldset">
                <legend class="admin-legend"><?php echo $this->translate('Form detail')?></legend>
            	<table width="100%" border="0">
                	<?php echo $tdForm;?>
                </table>
                <div class="clr"></div>
        	</fieldset>  
        </div>
       
        <div class="clr"></div>
	</div>
</div>
